package com.hdhere.application.service;

import com.hdhere.domain.common.util.EnumConvertUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/*******************************************************************************************
 * 类描述：  
 *
 * @author: dustin
 * @date: 2019-03-10 10:46
 * @Description:
 * @version 1.0
 *
 *
 * Version    Date       ModifiedBy                 Content  
 * -------- ---------    ----------         ------------------------  
 * 1.0      2019/3/10       dustin                               
 *******************************************************************************************
 */
@Service
public class BasicDataService {

    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    public List<Map<String, Object>> getEnumList(String enumName, String[] ids, Boolean include){

        Class enumClass = null;
        try {
            enumClass = Class.forName("com.hdhere.domain.common.enums." + enumName);
        }catch (Exception e){
            logger.error("获取枚举类出错：{}",e);
        }

        List<Map<String, Object>> list;
        if (ids != null && ids.length > 0) {
            if (include) {
                list = EnumConvertUtils.getListIn(enumClass, ids);
            } else {
                list = EnumConvertUtils.getListNotIn(enumClass, ids);
            }
        } else {
            list = EnumConvertUtils.getList(enumClass);
        }
        return list;
    }

    public List<Map<String, Object>> getEnumList(String enumName){

        return getEnumList(enumName, null, null);
    }
}
